
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QProcess>
#include<QDebug>
#include<QStringList>
#include<QString>
#include<windows.h>
#include<QScreen>
#include<QDate>
#include<QGuiApplication>
#include<QPixmap>


MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    //实现关机功能
    connect(ui->B1,&QToolButton::clicked,this,[=](){system("shutdown -s -t 00");});

    //实现截图功能
    connect(ui->B2,&QToolButton::clicked,this,[=](){
        QScreen *screen = QGuiApplication::primaryScreen();

        QString filePathName = "full-";

        filePathName += QDateTime::currentDateTime().toString("yyyy-MM-dd hh-mm-ss-zzz");

        filePathName += ".jpg";

        if(!screen->grabWindow(0).save(filePathName, "jpg"))

        {

//            qDebug()<<"save full screen failed";

        }
    });
}

MainWindow::~MainWindow()
{
    delete ui;
}

//void MainWindow::switchoff(){


//    system("shutdown -s -t 00");//直接用系统指令实现关机

//}




